<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/6/24
 * Time: 15:27
 */
// 取到班级信息
//var_dump($_POST);
$className =$_POST['class_name'] ?? '';

// 把班级信息存储到数据库
$dsn = "sqlsrv:Server=localhost;Database=Student";
$db = new PDO($dsn, "sa", "123456");

$sql = "insert into Class (ClassName) values('{$className}') ";
$result = $db->exec($sql);
if ($result) {
    echo '增加班级成功，前往<a href="list.php">列表页</a>';
} else {
    echo '添加失败';
}